<nz-spin *ngIf="isLoading" class="modal-spin"></nz-spin>
<form nz-form *ngIf="!isLoading" [formGroup]="validateForm" (ngSubmit)="submitForm()">
  <ng-container *ngIf="entity.role == 3 || entity.role == 4">
    <nz-form-item>
      <nz-form-label [nzSpan]="5" nzRequired nzFor="shopName"><span *ngIf="entity.role == 3">门店</span><span *ngIf="entity.role == 4">代理</span>名称</nz-form-label>
      <nz-form-control [nzSpan]="15" [nzValidateStatus]="validateForm.controls['shopName']">
        <input type="text" nz-input formControlName="shopName" placeholder="名称">
        <nz-form-explain *ngIf="validateForm.get('shopName').dirty && validateForm.get('shopName').hasError('required')">请输入名称</nz-form-explain>
        <nz-form-explain *ngIf="validateForm.get('shopName').dirty && validateForm.get('shopName').hasError('maxlength')">不能超过30个字</nz-form-explain>
      </nz-form-control>
    </nz-form-item>
    <nz-form-item>
      <nz-form-label [nzSpan]="5" nzRequired nzFor="typeId"><span *ngIf="entity.role == 3">门店</span><span *ngIf="entity.role == 4">代理</span>类别</nz-form-label>
      <nz-form-control [nzSpan]="15" [nzValidateStatus]="validateForm.controls['typeId']">
        <nz-select formControlName="typeId" [nzPlaceHolder]="'类别'">
          <nz-option
            *ngFor="let option of salesManTypeOption"
            [nzLabel]="option.name"
            [nzValue]="option.id">
          </nz-option>
        </nz-select>
        <nz-form-explain *ngIf="validateForm.get('typeId').dirty && validateForm.get('typeId').hasError('required')">请选择类型</nz-form-explain>
      </nz-form-control>
    </nz-form-item>
  </ng-container>
  <nz-form-item>
    <nz-form-label [nzSpan]="5" nzRequired nzFor="name"><span *ngIf="entity.role == 3 || entity.role == 4">负责人</span>姓名</nz-form-label>
    <nz-form-control [nzSpan]="15" [nzValidateStatus]="validateForm.controls['name']">
      <input type="text" nz-input formControlName="name" placeholder="姓名">
      <nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').hasError('required')">请输入姓名</nz-form-explain>
      <nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').hasError('maxlength')">不能超过30个字</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="5" nzRequired nzFor="phone"><span *ngIf="entity.role == 3 || entity.role == 4">负责人</span>手机号</nz-form-label>
    <nz-form-control [nzSpan]="15" [nzValidateStatus]="validateForm.controls['phone']">
      <input type="text" nz-input formControlName="phone" placeholder="手机号,请注意手机号即为其初始密码">
      <nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').hasError('required')">请输入手机号</nz-form-explain>
      <nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').hasError('mobileValidate')">手机号码格式不正确</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="5" nzRequired nzFor="idNumber"><span *ngIf="entity.role == 3 || entity.role == 4">负责人</span>身份证号</nz-form-label>
    <nz-form-control [nzSpan]="15" [nzValidateStatus]="validateForm.controls['idNumber']">
      <input type="text" nz-input formControlName="idNumber" placeholder="身份证号">
      <nz-form-explain *ngIf="validateForm.get('idNumber').dirty && validateForm.get('idNumber').hasError('required')">请输入身份证号</nz-form-explain>
    </nz-form-control>
  </nz-form-item>

  <nz-form-item>
    <nz-form-label [nzSpan]="5" nzRequired nzFor="districtId">运营中心</nz-form-label>
    <nz-form-control [nzSpan]="15" [nzValidateStatus]="validateForm.controls['districtId']">
      <nz-select formControlName="districtId" [nzPlaceHolder]="'运营中心'" [nzDisabled]="entity.id && entity.role != 1">
        <nz-option
          *ngFor="let option of districtOption"
          [nzLabel]="option.name"
          [nzValue]="option.id">
        </nz-option>
      </nz-select>
      <nz-form-explain *ngIf="validateForm.get('districtId').dirty && validateForm.get('districtId').hasError('required')">请选择运营中心</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <ng-container *ngIf="entity.role == 3 || entity.role == 4">
    <nz-form-item>
      <nz-form-label [nzSpan]="5" nzRequired nzFor="address"><span *ngIf="entity.role == 3">门店</span><span *ngIf="entity.role == 4">代理</span>地址</nz-form-label>
      <nz-form-control [nzSpan]="15" [nzValidateStatus]="validateForm.controls['address']">
        <input type="text" nz-input formControlName="address" placeholder="地址">
        <nz-form-explain *ngIf="validateForm.get('address').dirty && validateForm.get('address').hasError('required')">请输入地址</nz-form-explain>
        <nz-form-explain *ngIf="validateForm.get('address').dirty && validateForm.get('address').hasError('maxlength')">不能超过100个字</nz-form-explain>
      </nz-form-control>
    </nz-form-item>
  </ng-container>
  <div class="modal-footer" [ngStyle]="{ 'text-align': isModel?'right':'center','margin': isModel?'':'0'}" >
    <button nz-button type="button" *ngIf="isModel" (click)="close()">关闭</button>
    <button nz-button type="submit" [nzType]="'primary'" >保存</button>
  </div>
</form>
